<template>
	<view class="content">
		<view class="title-item">
			<view class="label">事项类别</view>
			<view class="value">{{CRMSomeThing.planBussType}}</view>
		</view>
		<view class="title-item">
			<view class="label">事项进展</view>
			<view :class="['value',{'success' : CRMSomeThing.statusName === '已完成','fail' : CRMSomeThing.statusName === '未完成','formal' : CRMSomeThing.statusName === '进行中'}]">{{CRMSomeThing.statusName}}</view>
		</view>
		<view class="title-item">
			<view class="label">事项开始时间</view>
			<view class="value">{{CRMSomeThing.planDayFrom}}</view>
		</view>
		<view class="title-item">
			<view class="label">预计所需时间</view>
			<view class="value">{{CRMSomeThing.planDayTo}}</view>
		</view>
		
		<map id="map" :latitude="latitude" :longitude="longitude" :markers="covers"></map>
		<view class="ipt">
			<u-input v-model="CRMSomeThing.biz3" type="textarea" :border="true" placeholder="备注" />
		</view>
		<!-- <view :class="['btn',{'over': CRMSomeThing.progress !== '未开始'}]" @click="somthingBeginClick">
			{{CRMSomeThing.progress !== '未开始' ? "事项已开始" : "事项开始"}}
		</view> -->
		<view :class="['btn']" @click="somthingEndClick">
			{{"事项已完成"}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				CRMSomeThing: null,
				id:0, // 使用 marker点击事件 需要填写id
				title: 'map',
				latitude: 39.909,
				longitude: 117.39742,
				covers: [{
					id: 0,
					height: 30,
					width: 20,
					latitude: 39.909,
					longitude: 117.39742,
				}]
			};
		},
		methods: {
			somthingBeginClick(){
				if(this.CRMSomeThing.progress === '未开始'){
					uni.showToast({
						title: '事项开始',
						icon: 'none'
					})
					this.CRMSomeThing.progress = "进行中"
				}
				
			},
			somthingEndClick(){
				this.$api.user.updateDayWork({
					id: this.CRMSomeThing.id,
					biz3: this.CRMSomeThing.biz3,
					status: "y"
				}).then((res) => {
					uni.showToast({
						title: '事项已完成',
						duration: 2000,
						success: () => {
							uni.navigateBack();
						}
					});
				})
			}
		},
		onLoad(){
			this.CRMSomeThing = uni.getStorageSync('CRMSomeThing');
			console.log("this11",this.CRMSomeThing);
			this.$forceUpdate()
			uni.setNavigationBarTitle({
				title: this.CRMSomeThing.title
			})
			uni.getLocation({
				type: 'gcj02', //返回可以用于uni.openLocation的经纬度
				success: function (res) {
					console.log("res",res);
					const latitude = res.latitude;
					const longitude = res.longitude;
					// uni.openLocation({
					// 	latitude: latitude,
					// 	longitude: longitude,
					// 	success: function () {
					// 		console.log('success');
					// 	},
					// 	fail: (e) => {
					// 		console.log(e);
					// 	}
					// });
				}
			});
		}
	}
	
</script>

<style lang="scss" scoped>
	.title-item{
		height: 80rpx;
		width: 100%;
		font-size: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
		font-weight: bold;
		.value{
			color: #2b85e4;
		}
		.label{
			color: #333;
		}
		.success{
			color: #19be6b;
			font-weight: bold;
		}
		.fail{
			color: #fa3534;
			font-weight: bold;
		}
		.formal{
			color: #2979ff;
			font-weight: bold;
		}
	}
	#map{
		width: 720rpx;
		height: 400rpx;
		margin: 20rpx 15rpx;
	}
	.btn-box{
		width: 100%;
		padding: 20rpx;
	}
	.ipt{
		width: 720rpx;
		margin: 10rpx 15rpx;
	}
	.btn{
		width: 720rpx;
		margin: 30rpx 15rpx;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background-color: #2b85e4;
		color: #fff;
		font-size: 30rpx;
		border-radius: 10rpx;
	}
	.over{
		background-color: #999;
	}
	.error{
		background-color: #fa3534;
	}
	
</style>
